import pandas as pd
import numpy as np
from datetime import datetime, timedelta
import os
os.makedirs("data/processed", exist_ok=True)

def generate_sample_data(num_samples=100, num_nodes=10):
    timestamps = [(datetime.now() + timedelta(minutes=i)).strftime("%Y-%m-%d %H:%M:%S") for i in range(num_samples)]
    data = []
    for i in range(num_samples):
        for node_id in range(num_nodes):
            row = {
                "timestamp": timestamps[i],
                "node_id": node_id,
                "flow": np.random.rand() * 100,
                "pressure": np.random.rand() * 10,
                "alarm": np.random.randint(0, 2),
                "user_id": np.random.randint(1000, 2000),
                "label": np.random.randint(0, 2)
            }
            data.append(row)
    df = pd.DataFrame(data)
    df.to_csv("data/processed/train.csv", index=False)
    print("✅ 模拟训练数据生成完成！")

if __name__ == "__main__":
    generate_sample_data()
